<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 10px !important;
}

.size {
	width: 550px;
	position: relative;
	left: 30%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>


	<title>Cadastro de Tipo de Determinação</title>
</h:head>

<h:body>
	<ui:decorate template="/templateBase.xhtml">

		<ui:define name="center">
			<p:growl id="growl" life="3000" autoUpdate="true" />

			<h:form prependId="true" id="formCadastroTipoDeterminacao">
				<br />
				<br />
				<br />
				<br />
				<p:panel header="Cadastro de Tipo de Determinação" styleClass="size"
					toggleable="true" id="panel"
					footer="SIGLAS - Sistema de Gerenciamento de Laboratório de Análise de Solo">

					<br />
					<div align="center">
						<h:panelGrid columns="3">
							<h:outputText value="Descrição: " />
							<p:inputText size="45" id="txtDesc"
								value="#{TipoDeterminacaoBacking.tipoDeterminacaoSalvar.descricao}"
								required="true" requiredMessage="Informe a descrição!" />
							<p:commandButton icon="ui-icon-search" immediate="true"
								oncomplete="dlg.show()" update=":formPesquisaTipo:tabelaTipo"
								actionListener="#{TipoDeterminacaoBacking.carregarTipoDeterminacao}"
								process="@all" />

						</h:panelGrid>
					</div>
					<br />

					<div align="center">
						<h:panelGrid columns="4">
							<p:commandButton value="Salvar"
								actionListener="#{TipoDeterminacaoBacking.salvar}"
								update=":formCadastroTipoDeterminacao:txtDesc"
								icon="ui-icon-disk" />
							<p:commandButton value="Cancelar"
								actionListener="#{TipoDeterminacaoBacking.reset}"
								update=":formCadastroTipoDeterminacao" icon="ui-icon-cancel" />
						</h:panelGrid>
					</div>
				</p:panel>
			</h:form>

			<h:form prependId="false" id="formPesquisaTipo">
				<p:dialog id="pesquisaTipo" widgetVar="dlg" appendToBody="true" modal="true"
					header="Pesquisar Tipo de Determinação" closable="true"
					height="450" width="400" resizable="false" showEffect="clip"
					hideEffect="clip">

					<p:dataTable var="t"
						value="#{TipoDeterminacaoBacking.listaTipoDeterminacao}" rows="10"
						widgetVar="TipoTabela" paginator="true" id="tabelaTipo"
						emptyMessage="Nenhum registro foi encontrado, tente novamente!">
						<h:outputText value="Tipos de Determinação cadastradas" />
						<p:column filterBy="#{t.descricao}">
							<f:facet name="header">
								<h:outputText value="Descrição" />
							</f:facet>
							<h:outputText value="#{t.descricao}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Ações" />
							</f:facet>

							<p:commandButton value="Alterar" onclick="dlg.hide()"
								icon="ui-icon-pencil"
								action="#{TipoDeterminacaoBacking.preparaAlteracao}"
								update=":formCadastroTipoDeterminacao:txtDesc" ajax="false">
								<f:setPropertyActionListener
									target="#{TipoDeterminacaoBacking.tipoDeterminacaoSelecionada}"
									value="#{t}" />
							</p:commandButton>

							<p:commandButton value="Excluir" icon="ui-icon-trash"
								update=":formPesquisaTipo:confirmaDelete"
								oncomplete="dlgDelete.show()" immediate="true" process="@all">
								<f:setPropertyActionListener
									target="#{TipoDeterminacaoBacking.tipoDeterminacaoSelecionada}"
									value="#{t}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</p:dialog>

				<p:dialog id="confirmaDelete" widgetVar="dlgDelete"
					header="Excluir registro" width="230" resizable="false"
					showEffect="clip" hideEffect="clip" closable="true">
					<br />
					<div align="center">
						<h:outputText value="Deseja realmente excluir?" />
						<br /> <br />
						<p:commandButton value="Sim"
							action="#{TipoDeterminacaoBacking.delete}"
							onsuccess="dlgDelete.hide()"
							update=":formPesquisaTipo:tabelaTipo" process="@all"
							immediate="true" />
						<p:commandButton value="Não" onclick="dlgDelete.hide()" />
					</div>
				</p:dialog>
			</h:form>


		</ui:define>
	</ui:decorate>
</h:body>
</html>